
package janino.compilador;

import java.io.IOException;
import java.io.InputStream;


/**
 * A {@link Resource} is "something" that is typically found by a
 * {@link org.codehaus.janino.util.resource.ResourceFinder}, can be {@link #open()}ed for
 * reading, and optionally has a {@link #lastModified()} property.
 * <p>
 * There also exists a {@link org.codehaus.janino.util.resource.ResourceCreator} concept which
 * opens a resource for writing, but that happens directly and not through an intermediate
 * {@link Resource} object.
 *
 * @see org.codehaus.janino.util.resource.ResourceFinder
 * @see org.codehaus.janino.util.resource.ResourceCreator
 */
public interface Resource {

    /**
     * Opens the resource. The caller is responsible for closing the
     * {@link java.io.InputStream}.
     */
    InputStream open() throws IOException;

    /**
     * Returns a decorative "file name" that can be used for reporting
     * errors and the like. It does not necessarily map to a file in the
     * local file system!
     */
    String getFileName();

    /**
     * Returns the time of the last modification, in milliseconds since
     * 1970, or <code>0L</code> if the time of the last modification cannot
     * be determined.
     */
    long lastModified();
}
